package com.gg.hc.service.impl;

import com.gg.common.mapper.MDesignProcedureModuleMapper;
import com.gg.common.pojo.DModuleDetails;
import com.gg.common.pojo.MDesignProcedureModule;
import com.gg.hc.search.PageVo;
import com.gg.hc.service.MDesignProcedureModuleService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MDesignProcedureModuleServiceImpl implements MDesignProcedureModuleService {

    @Resource
    private MDesignProcedureModuleMapper mDesignProcedureModuleMapper;


    @Override
    public int queryMDesignProcedureModuleByProductId(int productId) {
        return mDesignProcedureModuleMapper.queryMDesignProcedureModuleByProductId(productId);
    }

    @Override
    public int deleteMDesignProcedureModule(List<MDesignProcedureModule> mDesignProcedureModules) {
        return mDesignProcedureModuleMapper.deleteMDesignProcedureModule(mDesignProcedureModules);
    }

    @Override
    public int deleteDesignModuleByParentId(Integer parentId) {
        return mDesignProcedureModuleMapper.deleteDesignModuleByParentId(parentId);
    }

    @Override
    public int insertDModuleDetails(List<MDesignProcedureModule> mDesignProcedureModules) {
        return mDesignProcedureModuleMapper.insertDModuleDetails(mDesignProcedureModules);
    }

    @Override
    public int updateDModuleDetails(List<MDesignProcedureModule> mDesignProcedureModules) {
        return mDesignProcedureModuleMapper.updateDModuleDetails(mDesignProcedureModules);
    }

    @Override
    public List<MDesignProcedureModule> queryMDesignProcedureModuleByParentId(int id) {
        return mDesignProcedureModuleMapper.queryMDesignProcedureModuleByParentId(id);
    }

    @Override
    public int AddMDesignProcedureModule(MDesignProcedureModule mDesignProcedureModule) {
        return mDesignProcedureModuleMapper.AddMDesignProcedureModule(mDesignProcedureModule);
    }

    @Override
    public PageVo<MDesignProcedureModule> queryAll(PageVo pageVo) {
        PageHelper.offsetPage(pageVo.getPageNumber(),pageVo.getPageSize());
        List<MDesignProcedureModule> mDesignProcedureModules = mDesignProcedureModuleMapper.queryAll(pageVo);
        PageInfo pageInfo=new PageInfo(mDesignProcedureModules);
        PageVo<MDesignProcedureModule> pageVo1=new PageVo<>();
        pageVo1.setRows(pageInfo.getList());
        pageVo1.setTotal(pageInfo.getTotal());

        return pageVo1;
    }
}
